package com.zp.qualitypractice.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

/**
 * Created by izp on 2017/4/10.
 */

public abstract class SwipeViewBaseAdapter<T> extends BaseAdapter {
    protected Context mContext;
    protected List<T> mdata;
    protected LayoutInflater mInflater;
    private int mLayoutId;

    public SwipeViewBaseAdapter(Context mContext, List<T> mdata,int mLayoutId) {
        this.mContext = mContext;
        this.mdata = mdata;
        mInflater = LayoutInflater.from(mContext);
        this.mLayoutId = mLayoutId;
    }

    @Override
    public int getCount() {
        return mdata.size();
    }

    @Override
    public T getItem(int i) {
        return mdata.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        SwipeViewBaseViewHolder holder = SwipeViewBaseViewHolder.get(mContext, i, viewGroup,view ,mLayoutId);
        convert(holder, getItem(i));
        return holder.getmItemView();
    }

    public abstract void convert(SwipeViewBaseViewHolder holder, T t);


}
